package file;

import java.io.File;
import java.io.FileFilter;

/**
 * @author Luka
 * @date 2021/05/27 14:35
 *
 * 获取当前目录中含有t的子项
 *
 **/
public class Test {
    public static void main(String[] args) {
        File dir = new File(".");
        if(dir.isDirectory()){
            FileFilter filter = new FileFilter() {
                @Override
                public boolean accept(File pathname) {
                    String name = pathname.getName();
                    System.out.println("正在校验"+name);
                    return name.indexOf("t")>=0;

                }
            };

            File[] subs = dir.listFiles(filter);

            System.out.println("符合条件的有"+subs.length+"个");
        }
    }
}